export function Wechat_pay(data) {
  return Wechat.isInstalled(
    installed => {
      if (installed) {
        var params = {
          prepayid: data.backdata.prepayid, // prepay id
          noncestr: data.backdata.noncestr, // nonce
          timestamp: data.backdata.timestamp, // timestamp
          sign: data.backdata.sign, // signed string
          partnerid: data.backdata.partnerid // merchant id
        };
        Wechat.sendPaymentRequest(
          params,
          () => {
            this.$Spin.hide();
            this.$Modal.success({
              title: "成功",
              content: "支付成功"
            });
          },
          reason => {
            this.$Spin.hide();
            this.$Modal.info({
              title: "提示",
              content: reason
            });
          }
        );
      } else {
        this.$Spin.hide();
        this.$Modal.error({
          title: "失败",
          content: "您尚未安装微信"
        });
      }
    },
    reason => {
      this.$Spin.hide();
      alert("出现错误: " + reason);
    }
  );
}
